#! /bin/sh
# Trebol-A 2005 (info@trebol-a.com)
# http://www.trebol-a.com
#
# This script cropped your picture and create eight new images from shadows of superkaramba theme a-foto

# Use: ./recorte.sh file.png border_top border_left border_right border_bottom
# Example: ./recorte.sh wood.png 10 10 10 20


ancho=`identify -format '%w' $1`
alto=`identify -format '%h' $1`

convert -crop $3x$2+0+0 $1 "s_aa.png"
convert -crop `expr $ancho - $3 - $4`x$2+$3+0 $1 "s_ab.png"
convert -crop $4x$2+`expr $ancho - $4`+0 $1 "s_ac.png"

convert -crop $3x`expr $alto - $2 - $5`+0+$2 $1 "s_ba.png"
convert -crop $4x`expr $alto - $2 - $5`+`expr $ancho - $4`+$2 $1 "s_bc.png"

convert -crop $3x$5+0+`expr $alto - $5` $1 "s_ca.png"
convert -crop `expr $ancho - $3 - $4`x$5+$3+`expr $alto - $5` $1 "s_cb.png"
convert -crop $4x$5+`expr $ancho - $4`+`expr $alto - $5` $1 "s_cc.png"

echo "Trabajo hecho!! :D "
